<%@ page import="entity.ShoppingCart" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="entity.GoodsItem" %>
<%@ page import="entity.Commodity" %><%--
  Created by IntelliJ IDEA.
  User: 浮犴兮
  Date: 2022/4/6
  Time: 20:01
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>购物车页面</title>
    <style>
        table {
            margin: 80px auto 0 auto;
            border: 1px black solid;
            font-size: 24px;
            border-spacing: 0;
            border-top: 1px solid black;
            border-left: 1px solid black;
        }

        table thead {
            table-layout: fixed;
            background-color: #F45B4B;
            /*display: table;*/
            width: 100%;
        }

        .tdStyle td {
            padding: 10px;
            border-right: 1px solid black;
            border-bottom: 1px solid black;
            border-collapse: collapse;
        }
    </style>
</head>
<body>
<div style="padding-top:30px;padding-left: 35px">
    <a href="CommodityListController" style="color: #F45B4B;font-size: 24px">⬅返回继续购物</a>
</div>
<h1 align="center" style="padding-top: 30px">购物车列表</h1>
<table class="tdStyle" style="height: 100px">
    <thead>
    <tr>
        <td>商品条形码</td>
        <td>商品名称</td>
        <td>商品类型</td>
        <td>商品价格</td>
        <td>商品数量</td>
        <td>修改该商品数量</td>
        <td>移除该商品</td>
    </tr>
    </thead>
    <tbody>
    <%
        ShoppingCart cart = (ShoppingCart) session.getAttribute("shoppingcart");
        ArrayList<GoodsItem> items = new ArrayList<>(cart.getMap());
        for (GoodsItem goodsItem : items) {
            Commodity commodity = goodsItem.getCommodity();
    %>
    <tr>
        <td><%=commodity.getcId()%>
        </td>
        <td><%=commodity.getcName()%>
        </td>
        <td><%=commodity.getcKind().toString()%>
        </td>
        <td><%=commodity.getcPrice()%>
        </td>
        <td><%=goodsItem.getQuality()%>
        </td>
        <td>
            <a href="/CommodityListController?method=toShoppingCar&cId=<%=commodity.getcId()%>&quality=<%=goodsItem.getQuality()%>">修改</a>
        </td>
        <td><a href="/ShoppingCart?cId=<%=commodity.getcId()%>">删除</a></td>
    </tr>
    <%}%>
    <tr>
        <td colspan="4" style="text-align: center">总计:</td>
        <td colspan="5"><%=cart.getTotal()%>
        </td>
    </tr>
    </tbody>
</table>
</body>
</html>
